package com.mz.ozy.activity.me;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import com.flyco.tablayout.SlidingTabLayout;
import com.mz.ozy.R;
import com.mz.ozy.adapter.MyOrderFragmentAdapter;
import com.mz.ozy.base.BaseActivity;

import androidx.annotation.Nullable;
import androidx.viewpager.widget.ViewPager;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2018/11/22.
 * 我的订单
 */

public class MyOrderActivity extends BaseActivity {

    public static int mOrderPosition = 0;

    private String[] titles;
    @BindView(R.id.tl_tab_layout)
    SlidingTabLayout mTlTabLayout;
    @BindView(R.id.vp_view_pager)
    ViewPager mVpViewPager;
    private int mType;

    public static void start(Context context, int type) {
        Intent starter = new Intent(context, MyOrderActivity.class);
        starter.putExtra("type", type);
        context.startActivity(starter);
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_order);
        ButterKnife.bind(this);
        initTitle();
        tvCenterTitle.setText(R.string.str_my_order_title);
        // MyOrderFragment
        //  MyOrderFragmentAdapter
        //初始化tabLayout  ViewPage

        mType = getIntent().getIntExtra("type", MyOrderFragment.TYPE_ALL);
        titles = getResources().getStringArray(R.array.order_tab);
        mVpViewPager.setAdapter(new MyOrderFragmentAdapter(getSupportFragmentManager()));
        mTlTabLayout.setViewPager(mVpViewPager, titles);

        switch (mType) {
            case MyOrderFragment.TYPE_ALL:
                mOrderPosition = 0;
                mVpViewPager.setCurrentItem(0);
                break;
            case MyOrderFragment.TYPE_PAY:
                mOrderPosition = 1;
                mVpViewPager.setCurrentItem(1);
                break;
            case MyOrderFragment.TYPE_SEND:
                mOrderPosition = 2;
                mVpViewPager.setCurrentItem(2);
                break;
            case MyOrderFragment.TYPE_RECEIVE:
                mOrderPosition = 3;
                mVpViewPager.setCurrentItem(3);
                break;
            case MyOrderFragment.TYPE_REFUND:
                mOrderPosition = 4;
                mVpViewPager.setCurrentItem(4);
                break;
        }
    }
}
